<div id="page_content">
    <?php if (!isset($this->fielddata)) { ?>
        <h2><?php echo $this->t->_("New field") ?></h2>
    <?php } else { ?>
        <h2><?php echo $this->fielddata['title'] ?></h2>
    <?php } echo $this->form ?>
</div>

<div id="sidebar">
    <?php if (isset($this->formdata)) { ?>
        <a href="<?php echo ADMIN_URL . '/forms/field/fid/' . $this->formdata['id'] ?>" class="sidebar_button add_button"><?php echo $this->t->_("New field") ?></a>
        <br /><a href="#" id="<?php echo ADMIN_URL . '/forms/deletefield/id/' . $this->fielddata['id'] . '/fid/' . $this->fielddata['fid'] ?>" class="sidebar_button delete_button"><?php echo $this->t->_("Delete field") ?></a>
    <?php } ?>
</div>

<script type="text/javascript">
    hides = "#where-label, #where-element,#order-label, #order-element,#table_field-label,#table_field-element,#table-label,#table-element";
    hidei = "#image_width-label, #image_width-element, #image_height-label, #image_height-element, #preview-label, #preview-element";
    hidep = "#preview_width-label, #preview_width-element, #preview_height-label,#preview_height-element";
    hidet = "#identifier-label, #identifier-element";
    
    $(hides + ', ' + hidei + ', ' + hidep + ', ' + hidet).hide();
    
    if ($("#type").val() == 'select') {
        $(hides).show();
    }
    
    if ($("#type").val() == 'image') {
        $(hidei).show();
    } 
    
    if ($("#preview").is(":checked")) {
        $(hidep).show();
    } 
    
    if ($("#type").val() == 'tags') {
        $(hidet).show();
    } 
    
    $("#type").change(function () {
        $(hides + ', ' + hidei + ', ' + hidep).hide();
        
        if ($(this).val() == 'select') {
            $(hides).show();
        } 
        
        if ($(this).val() == 'image') {
            $(hidei).show();
        } 
        
        if ($(this).val() == 'tags') {
            $(hidet).show();
        } 
        
    });
    
    $("#preview").change(function () {
        $(hides + ', ' + hidep).hide();
        if ($(this).is(":checked")) {
            $(hidep).show();
        } else {
            $(hidep).hide();
        }
    });
    
</script>
